package rescsa.gob.pe.defecto.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import rescsa.gob.pe.actividad.bean.ActividadBEAN;
import rescsa.gob.pe.defecto.bean.DefectoBEAN;
import rescsa.gob.pe.defecto.service.DefectoService;
import rescsa.gob.pe.defecto.service.DefectoServiceImplementacion;

import com.opensymphony.xwork2.ActionSupport;

@ParentPackage(value="requerimiento")
public class Defecto extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private DefectoServiceImplementacion defectoi=new DefectoServiceImplementacion();
	private List<DefectoBEAN> defectos;
	private String oper;
	private String id;
//	private DefectoBEAN defecto;
//	private DefectoService idefecto;
	
//	public Defecto(){
//		defecto=new DefectoBEAN();
//		idefecto=new DefectoServiceImplementacion();
//	}
	
	public String listadefecto(){
		System.out.println("listadefecto");
		return SUCCESS;
	}
	
//	public String verDefecto(){
//		System.out.println("verDefecto");
//		System.out.println("Defecto "+defecto.getCodigo_defecto());
//		try {
//			defecto=idefecto.ObtenerDefectos(defecto.getCodigo_defecto());
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		
//		return SUCCESS;
//	}
	
	@Action(value="/ListaDefectosAction",results={@Result(name="success",type="json")})
	public String ListaDefectos() throws Exception{
		System.out.println("ListaDefectosAction");		
		defectos=defectoi.ListaDefectos();
		return SUCCESS;
	}
	
	@Action(value="/ListaDefectosActividadAction",results={@Result(name="success",type="json")})
	public String ListaDefectosActividad() throws Exception{
		System.out.println("ListaDefectosActividad");
		System.out.println("id "+id);
		defectos=defectoi.ListaDefectosActividad(id);
		System.out.println("size "+defectos.size());
		return SUCCESS;
	}
	
	public DefectoServiceImplementacion getDefectoi() {
		return defectoi;
	}
	public void setDefectoi(DefectoServiceImplementacion defectoi) {
		this.defectoi = defectoi;
	}
	public String getOper() {
		return oper;
	}
	public void setOper(String oper) {
		this.oper = oper;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public List<DefectoBEAN> getDefectos() {
		return defectos;
	}
	public void setDefectos(List<DefectoBEAN> defectos) {
		this.defectos = defectos;
	}
//	public DefectoBEAN getDefecto() {
//		return defecto;
//	}
//	public void setDefecto(DefectoBEAN defecto) {
//		this.defecto = defecto;
//	}
//	public DefectoService getIdefecto() {
//		return idefecto;
//	}
//	public void setIdefecto(DefectoService idefecto) {
//		this.idefecto = idefecto;
//	}
}
